Solving 10385 - Duathlon (Ternary search)
[andmenj-acm.git] / 10921 - Find the telephone / 10921.cpp
blob1766a403f0ec7f578df2399444012d9f0fb60019
1 #include <iostream>
2 #include <string>
4 using namespace std;
6 string l[] = {"0", "1", "ABC", "DEF", "GHI", "JKL", "MNO", "PQRS", "TUV", "WXYZ"};
8 int translate(char c){
9 for (int i=0; i<10; ++i){
10 if (l[i].find(c) != string::npos){
11 return i;
14 return -1;
17 int main(){
18 string s;
19 while (getline(cin, s)){
20 for (int i=0; i<s.size(); ++i){
21 if (s[i] == '-') cout << "-";
22 else cout << translate(s[i]);
24 cout << endl;
26 return 0;